<template>
	<view class="order">
		<view class="top">
			<view class="top_t">
				商品信息
			</view>
			<view class="top_content" v-if="order!=''">
				<view class="c_left">
					<view class="l_img">
						<image :src="http + order.ticket.image" mode=""></image>
					</view>
				</view>
				<view class="c_right">
					<view class="l_text">
						<view class="text_top">
							{{order.ticket.title}}
						</view>
						<view class="text_bottom">
							{{order.spec}}
						</view>
					</view>
					<view class="">
						<view class="c_money">
							<text>￥</text>{{order.oneprice}}
						</view>
						<view class="c_num">
							<text>x</text>{{order.number}}
						</view>
					</view>
				</view>
			</view>
		</view>
		
		<view class="msg">
			<view class="msg_list">
				<view class="m_left">
					使用日期
				</view>
				<view class="m_right">
					{{order.daytime}}
				</view>
			</view>
			<view class="msg_list">
				<view class="m_left">
					联系人
				</view>
				<view class="m_right">
					{{order.contactname}}
				</view>
			</view>
			<view class="msg_list">
				<view class="m_left">
					联系电话
				</view>
				<view class="m_right">
					{{order.contactphone}}
				</view>
			</view>
			<view class="msg_list">
				<view class="m_left">
					身份证号
				</view>
				<view class="m_right">
					{{order.id_card}}
				</view>
			</view>
			<view class="msg_list">
				<view class="m_left">
					核销日期
				</view>
				<view class="m_right">
					{{$formatDate(order.usetime*1000)}}
				</view>
			</view>
		</view>
		<view class="msg">
			<view class="title">
				凭证码：{{code}}
			</view>
			<view class="code">
				<image v-if="order.verifyimg" :src="http+order.verifyimg" mode=""></image>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				id: 0,
				code: 0,
				order: '',
				http: this.$http,
			}
		},
		onLoad(o) {
			if (uni.getStorageSync('user')){
				this.code = o.code
				this.id = uni.getStorageSync('user').id
				let rand = Math.floor(Math.random() * 100)
				this.$post('home/orderDetail', {
					code: this.code,
					mid: this.id,
					rand: rand
				}).then(res => {
					console.log(res)
					if (res.code == 0) {
						this.order = res.data
					}
				})
			}
		},
		computed: {
			getTime() {
				return (timestamp) => {
					// 此处时间戳以毫秒为单位
					let date = new Date(parseInt(timestamp) * 1000);
					let Year = date.getFullYear();
					let Moth = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1);
					let Day = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate());
					let GMT = Year + '-' + Moth + '-' + Day
					return GMT
				}
			}
		},
		methods: {

		}
	}
</script>

<style lang="less">
	page {
		background-color: #f7f7f7;
	}

	.order {
		image {
			width: 100%;
			height: 100%;
		}
		.top {
			background-color: #FFFFFF;
			padding: 24rpx 34rpx;

			.top_t {
				font-size: 26rpx;
				font-weight: 700;
				color: #333333;
			}

			.top_content {
				display: flex;
				align-items: center;
				margin-top: 30rpx;
				.c_left {
					display: flex;
					align-items: center;
					.l_img {
						width: 160rpx;
						height: 136rpx;
					}



				}

				.c_right {
					color: #333333;
					display: flex;
					align-items: center;
					justify-content: space-between;
					flex: 1;
					.l_text {
						margin-left: 14rpx;
						color: #333333;
					
						.text_top {
							font-size: 28rpx;
							font-weight: 700;
						}
					
						.text_bottom {
							color: #888888;
							font-size: 22rpx;
							margin-top: 20rpx;
						}
					}
					.c_money {
						width: 100%;
						font-size: 26rpx;

						text {
							font-size: 22rpx;
						}
					}

					.c_num {
						width: 100%;
						margin-top: 10rpx;
						font-size: 34rpx;
						text-align: right;

						text {
							font-size: 30rpx;
						}
					}
				}
			}
		}

		.msg {
			background-color: #FFFFFF;
			margin-top: 12rpx;
			padding: 0rpx 34rpx;

			.msg_list {
				padding-top: 32rpx;
				padding-bottom: 32rpx;
				display: flex;
				align-items: center;
				border-bottom: 1rpx solid #f5f5f5;

				.m_left {
					width: 150rpx;
					font-size: 26rpx;
					color: #666666;
					font-weight: 500;
				}

				.m_right {
					font-size: 24rpx;
					font-weight: 700;
					color: #333333;
				}
			}

			.title {
				font-size: 30rpx;
				font-weight: 700;
				color: #333333;
				padding-top: 20rpx;
				padding-bottom: 20rpx;
			}

			.code {
				width: 220rpx;
				height: 220rpx;
				margin: 0 auto;
				padding-top: 24rpx;
				padding-bottom: 52rpx;
			}
		}
	}
</style>